package mainServer;

import interaction.ProtocolType;


public class ServerFactory
{
  private IServer makeUdpServer(int port)
  {
    return new UdpServer(port);
  }
  
  private IServer makeTcpServer(int port)
  {
    return new TcpServer(port);
  }
  
  private IServer makeRmiServer(int port)
  {
    return new RmiServer(port);
  }
  
  private IServer makeCorbaServer(int port)
  {
    return new CorbaServer(port);
  }
  
  public IServer makeServer(ProtocolType type, int port)
  {
    switch (type)
    {
    case UDP:
      return makeUdpServer(port);      
    case TCP:
      return makeTcpServer(port);      
    case RMI:
      return makeRmiServer(port);      
    case CORBA:
      return makeCorbaServer(port);
    default:
      System.out.println("Запрошен недопустимый протокол");
      return null;
    }
  }
}
